package day04;

import java.util.Scanner;

/**
 * @author wangzhisen
 * @Desc TODO
 * @date 2025/4/12
 */

//需求1：定义整型数组，从键盘输入5个元素，并求其最大值

public class TestOneArray01 {
    public static void main(String[] args) {
        int[] arr = new int[5];
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入 5 个整数");
        for (int i = 0; i < arr.length; i++) {
            System.out.print("请输入第 " + (i + 1) + " 个整数：");
            arr[i] = scanner.nextInt();
        }
        int max = arr[0];
        for (int i = 1; i < arr.length; i++) {
            if (arr[i] > max) {
                max = arr[i];
            }
        }
        System.out.println("数组中的最大值是：" + max);
    }
}
